<?php
namespace app\admin\validate;

use \think\Validate;

class Category extends Validate
{
    use \app\common\validate\Validate;

    protected $autoWriteTimestamp = true;
    //protected $updateTime = false;

    protected $rule = [
        'title'         => ['require', 'max:100'],
        'type_id'       => ['require', 'exist:cate_type'],
        'description'   => ['require','max:255'],
        'pid'           => ['require', 'existPid:category'],
        'key'           => ['require','unique:category,key'],//存在的问题,这里应该不被允许更改!
        'keyword'       => ['max:100'],
        'sort'          => ['integer'],
    ];

    protected $message = [
        'pid.require'       => '上级单页面必须填写',
        'pid.existPid'      => '上级单页面不存在或者不能等于本身',
        'key.unique'        => 'KEY已经存在',
        'title.require'     => '标题必须填写',
        'title.max'         => '标题长度不能超来100个字符',
        'keyword.max'       => '关键词长度不能超来100个字符',
        'description.max'   => '简介长度不能超来100个字符',
        'sort.require'      => '排序必须填写',
        'sort.integer'      => '排序值不正确',

    ];

    protected $scene = [
        'add'  => ['pid', 'key', 'title', 'description', 'keyword', 'sort'],
        'edit' => ['pid','title','description','keyword','sort'],
    ];


}
